<?php
namespace Particle\Core;
use Particle\Core;

/**
 * @package Particle
 * @category Core
 * @author dertin
 * @abstract
 **/


abstract class Model
{
    private static $_DBInstance = null;
    
    protected $_db;
    
    protected function __construct($loadModelDB = DB_FLAG) {
        
        if(DB_FLAG){
            
            if(!self::$_DBInstance){
                self::$_DBInstance = new Core\Database;
            }
            if($loadModelDB){
                $this->_db = self::$_DBInstance->connectDBPDODefault();
            }
        }else{
            $this->_db = null;
        }
        
    }
    
    protected final function connectDBNew($dbHost, $dbName, $dbUser, $dbPass, $dbChar){
        $this->_db = self::$_DBInstance->connectDBPDONew($dbHost, $dbName, $dbUser, $dbPass, $dbChar);   
    }
    
    protected final function connectDBDefault(){
        $this->_db = self::$_DBInstance->connectDBPDODefault();
    }
    
    protected final function closeDB(){
        $this->_db = self::$_DBInstance->closeDBPDO();
    }
    
}